﻿package src {
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	public final class Debug extends Sprite {
		//Debug output, kevin 2009
		public static function show(str:Object = null):void {
			var lc:LocalConnection = new LocalConnection();
			lc.addEventListener(StatusEvent.STATUS, function(e:Event):void{});
			var s:String = "("+ Math.round(System.totalMemory/1000)/1000 +"M) "+str.toString();
			trace(s);
			lc.send("_debug_lc", "Trace", s);
		}
		
		public function Debug():void {
			draw();
			
			
			CP.addEventListener(E.RESIZE,resizeHandler);
			
		}
		
		private function draw():void {
			var size:Number = 300;
			var a:Number = 0.5;
			//
			var xline:Sprite = line(0xff0000, size, a, "X");
			addChild(xline);
			var yline:Sprite = line(0x00ff00, size, a, "Y");
			yline.rotationZ = 90;
			addChild(yline);
			var zline:Sprite = line(0x0000ff, size, a, "Z");
			zline.rotationY = - 90;
			addChild(zline);
		}
		
		private function line(color:Number, size:Number, alpha:Number, name:String):Sprite {
			var sp:Sprite = new Sprite();
			with (sp.graphics) {
				lineStyle(1, color, alpha, true);
				moveTo(- size, 0);
				lineTo(size, 0);
			}
			var t:TextField = new TextField();
			t.selectable = false;
			t.autoSize = "left";
			t.htmlText = name;
			t.setTextFormat(new TextFormat("Arial", 12, color));
			t.x = size;
			t.y = - t.height * 0.5;
			sp.addChild(t);
			return sp;
		}
		
		
		private function resizeHandler(e:E=null):void {
			
			
			
		}
		
		
	}
	
}
